﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Security.Cryptography;

namespace SecurityLib
{
    /// <summary>
    /// Summary description for PasswordHasher
    /// </summary>
    public class PasswordHasher
    {
        private static SHA1Managed hasher = new SHA1Managed();
        public PasswordHasher()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        public static string Hash(string password)
        {
            // convert password to byte array
            byte[] passwordBytes =
            System.Text.ASCIIEncoding.ASCII.GetBytes(password);
            // generate hash from byte array of password
            byte[] passwordHash = hasher.ComputeHash(passwordBytes);
            // generate hash from byte array of password
            return Convert.ToBase64String(passwordHash, 0,
            passwordHash.Length);
        }
    }
}